﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using Newtonsoft.Json.Linq;

namespace Sina.Altman.Weibo.SDK.Objects
{
    /// <summary>
    /// 热门话题集合
    /// </summary>
    public class Trends
    {
        public Trends(string json)
            : this(JObject.Parse(json))
        {
        }

        private JObject __jobject;
        public Trends(JObject obj)
        {
            this.__jobject = obj;
        }

        [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
        private Trends2 _trends2Item;
        public Trends2 Trends2Item
        {
            get
            {
                if (_trends2Item == null)
                    _trends2Item = JsonClassHelper.ReadStronglyTypedObject<Trends2>(JsonClassHelper.GetJToken<JObject>(__jobject, "trends"));
                return _trends2Item;
            }
        }

        public int AsOf
        {
            get
            {
                return JsonClassHelper.ReadInteger(JsonClassHelper.GetJToken<JValue>(__jobject, "as_of"));
            }
        }
    }

    /// <summary>
    /// 热门话题
    /// </summary>
    public class Trend
    {
        private JObject __jobject;
        public Trend(JObject obj)
        {
            this.__jobject = obj;
        }

        public string Name
        {
            get
            {
                return JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "name"));
            }
        }

        public string Query
        {
            get
            {
                return JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "query"));
            }
        }

        public string Amount
        {
            get
            {
                return JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "amount"));
            }
        }

        public string Delta
        {
            get
            {
                return JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "delta"));
            }
        }
    }

    /// <summary>
    /// 热门话题解析过渡类
    /// </summary>
    public class Trends2
    {

        private JObject __jobject;
        public Trends2(JObject obj)
        {
            this.__jobject = obj;
        }

        [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
        private Trend[] _trend;
        public Trend[] Trend
        {
            get
            {
                if (_trend == null)
                    _trend = (Trend[])JsonClassHelper.ReadArray<Trend>(JsonClassHelper.GetJToken<JArray>(__jobject, "trend"), JsonClassHelper.ReadStronglyTypedObject<Trend>, typeof(Trend[]));
                return _trend;
            }
        }

    }
}
